<?php
	$tabela = new Standings($settings->activeLeague, 1);
	$tabela->getTeams();
	$tabela->getTeamsStats();
	$tabela->sortTeams();
?>


            <div class="twoCollumns">
            	<div class="leftCollumn">

                	<div class="leftBox">
                    	<table class="tabela tabelatandings" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                            	<td>#</td>
                            	<td>Tim</td>
                            	<td></td>
                            	<td>W</td>
                            	<td>L</td>
                            	<td>S</td>
                            	<td>C</td>
                            	<td>D</td>
                            	<td>Pt</td>
                            </tr>
                        </thead>
                        <tbody>
                        
                        <?php
							$poz = 1;
							foreach ($tabela->tabela as $tim) {
						?>
                        	<tr>
                            	<td class="tabelaPosition"><?php echo $poz++; ?></td>
                            	<td class="tabelaCrest"><img src="media/teams/logo/<?php echo $tim->grb; ?>" height="60" /></td>
                            	<td class="tabelaName"><a href="team/<?php echo $tim->id; ?>/<?php echo str_replace(" ", "-", $tim->ime); ?>"><?php echo $tim->ime; ?></a></td>
                             	<td class="tabelaPoints"><?php echo $tim->wins; ?></td>
                            	<td class="tabelaPoints"><?php echo $tim->loses; ?></td>
                            	<td class="tabelaPoints"><?php echo $tim->pts; ?></td>
                            	<td class="tabelaPoints"><?php echo $tim->conceded; ?></td>
                             	<td class="tabelaPoints"><?php printf('%+d', ($tim->pts - $tim->conceded)); ?></td>
                                <td class="tabelaPoints"><?php echo $tim->brojPoena; ?></td>
                            </tr>
                        <?php
							}
						?>
                        </tbody>
                        </table>
                    </div>
                    <h3 class="smallBoxTitle"><a href="#">Standings</a></h3>
                    
                </div>
                
                <div class="rightCollumn">
                
                    <?php
						$leaderboard = new Leaderboard(1);
						$leaderboard->getPlayersList();
						$leaderboard->fillPlayersStats();
					?>
                
                	<div class="smallBox">
                    
                    <?php 
						$leaderboard->sortPlayers("pts");
						$limit = 3;
						if (count($leaderboard->igraci) < 3) $limit = count($leaderboard->igraci);
						
						for ($i=0; $i<$limit; $i++) {
					?>
                    	<div class="leagueLeader">
                        
                        	<div class="leagueLeaderImg">
                            	<img src="media/players/<?php echo $leaderboard->igraci[$i]->slika; ?>" />
                            </div>
                            
                            <div class="leagueLeaderName">
                            	<a href="player/<?php echo $leaderboard->igraci[$i]->id; ?>/<?php echo $leaderboard->igraci[$i]->ime . "-" . $leaderboard->igraci[$i]->prezime; ?>"><?php echo $leaderboard->igraci[$i]->ime; ?> <?php echo $leaderboard->igraci[$i]->prezime; ?></a>
                                <br />
                                <a class="leagueLeaderTeam" href="team/<?php echo $leaderboard->igraci[$i]->getTeamInfo()->id; ?>/<?php echo str_replace(" ", "-", $leaderboard->igraci[$i]->getTeamInfo()->ime); ?>"><?php echo $leaderboard->igraci[$i]->getTeamInfo()->ime; ?></a>
                            </div>
                            
                            <div class="leagueLeaderScore">
                            	<span class="leagueLeaderScoreNumber"><?php echo $leaderboard->igraci[$i]->totalStats->pts; ?></span>
                            </div>
                        </div>
                        
                    <?php
						}
					?>
                    </div><!-- end of .leagueLeaders -->
                    <h3 class="smallBoxTitle"><a href="#">Points</a></h3>
                                        
                	<div class="smallBox">
                    <?php 
						$leaderboard->sortPlayers("ast");
						$limit = 3;
						if (count($leaderboard->igraci) < 3) $limit = count($leaderboard->igraci);
						
						for ($i=0; $i<$limit; $i++) {
					?>
                    	<div class="leagueLeader">
                        
                        	<div class="leagueLeaderImg">
                            	<img src="media/players/<?php echo $leaderboard->igraci[$i]->slika; ?>" />
                            </div>
                            
                            <div class="leagueLeaderName">
                            	<a href="player/<?php echo $leaderboard->igraci[$i]->id; ?>/<?php echo $leaderboard->igraci[$i]->ime . "-" . $leaderboard->igraci[$i]->prezime; ?>"><?php echo $leaderboard->igraci[$i]->ime; ?> <?php echo $leaderboard->igraci[$i]->prezime; ?></a>
                                <br />
                                <a class="leagueLeaderTeam" href="team/<?php echo $leaderboard->igraci[$i]->getTeamInfo()->id; ?>/<?php echo str_replace(" ", "-", $leaderboard->igraci[$i]->getTeamInfo()->ime); ?>"><?php echo $leaderboard->igraci[$i]->getTeamInfo()->ime; ?></a>
                            </div>
                            
                            <div class="leagueLeaderScore">
                            	<span class="leagueLeaderScoreNumber"><?php echo $leaderboard->igraci[$i]->totalStats->ast; ?></span>
                            </div>
                        </div>
                        
                    <?php
						}
					?>

                    </div><!-- end of .leagueLeaders -->
                    <h3 class="smallBoxTitle"><a href="#">Assists</a></h3>
                                        
                	<div class="smallBox">
                    <?php 
						$leaderboard->sortPlayers("totalRbd");
						$limit = 3;
						if (count($leaderboard->igraci) < 3) $limit = count($leaderboard->igraci);
						
						for ($i=0; $i<$limit; $i++) {
					?>
                    	<div class="leagueLeader">
                        
                        	<div class="leagueLeaderImg">
                            	<img src="media/players/<?php echo $leaderboard->igraci[$i]->slika; ?>" />
                            </div>
                            
                            <div class="leagueLeaderName">
                            	<a href="player/<?php echo $leaderboard->igraci[$i]->id; ?>/<?php echo $leaderboard->igraci[$i]->ime . "-" . $leaderboard->igraci[$i]->prezime; ?>"><?php echo $leaderboard->igraci[$i]->ime; ?> <?php echo $leaderboard->igraci[$i]->prezime; ?></a>
                                <br />
                                <a class="leagueLeaderTeam" href="team/<?php echo $leaderboard->igraci[$i]->getTeamInfo()->id; ?>/<?php echo str_replace(" ", "-", $leaderboard->igraci[$i]->getTeamInfo()->ime); ?>"><?php echo $leaderboard->igraci[$i]->getTeamInfo()->ime; ?></a>
                            </div>
                            
                            <div class="leagueLeaderScore">
                            	<span class="leagueLeaderScoreNumber"><?php echo $leaderboard->igraci[$i]->totalStats->totalRbd; ?></span>
                            </div>
                        </div>
                        
                    <?php
						}
					?>
                    </div><!-- end of .leagueLeaders -->
                    <h3 class="smallBoxTitle"><a href="#">Rebounds</a></h3>
                                        
                	<div class="smallBox">
                    <?php 
						$leaderboard->sortPlayers("blk");
						$limit = 3;
						if (count($leaderboard->igraci) < 3) $limit = count($leaderboard->igraci);
						
						for ($i=0; $i<$limit; $i++) {
					?>
                    	<div class="leagueLeader">
                        
                        	<div class="leagueLeaderImg">
                            	<img src="media/players/<?php echo $leaderboard->igraci[$i]->slika; ?>" />
                            </div>
                            
                            <div class="leagueLeaderName">
                            	<a href="player/<?php echo $leaderboard->igraci[$i]->id; ?>/<?php echo $leaderboard->igraci[$i]->ime . "-" . $leaderboard->igraci[$i]->prezime; ?>"><?php echo $leaderboard->igraci[$i]->ime; ?> <?php echo $leaderboard->igraci[$i]->prezime; ?></a>
                                <br />
                                <a class="leagueLeaderTeam" href="team/<?php echo $leaderboard->igraci[$i]->getTeamInfo()->id; ?>/<?php echo str_replace(" ", "-", $leaderboard->igraci[$i]->getTeamInfo()->ime); ?>"><?php echo $leaderboard->igraci[$i]->getTeamInfo()->ime; ?></a>
                            </div>
                            
                            <div class="leagueLeaderScore">
                            	<span class="leagueLeaderScoreNumber"><?php echo $leaderboard->igraci[$i]->totalStats->blk; ?></span>
                            </div>
                        </div>
                        
                    <?php
						}
					?>
                    </div><!-- end of .leagueLeaders -->
                    <h3 class="smallBoxTitle"><a href="#">Blocks</a></h3>
                                        
                	<div class="smallBox">
                    <?php 
						$leaderboard->sortPlayers("stl");
						$limit = 3;
						if (count($leaderboard->igraci) < 3) $limit = count($leaderboard->igraci);
						
						for ($i=0; $i<$limit; $i++) {
					?>
                    	<div class="leagueLeader">
                        
                        	<div class="leagueLeaderImg">
                            	<img src="media/players/<?php echo $leaderboard->igraci[$i]->slika; ?>" />
                            </div>
                            
                            <div class="leagueLeaderName">
                            	<a href="player/<?php echo $leaderboard->igraci[$i]->id; ?>/<?php echo $leaderboard->igraci[$i]->ime . "-" . $leaderboard->igraci[$i]->prezime; ?>"><?php echo $leaderboard->igraci[$i]->ime; ?> <?php echo $leaderboard->igraci[$i]->prezime; ?></a>
                                <br />
                                <a class="leagueLeaderTeam" href="team/<?php echo $leaderboard->igraci[$i]->getTeamInfo()->id; ?>/<?php echo str_replace(" ", "-", $leaderboard->igraci[$i]->getTeamInfo()->ime); ?>"><?php echo $leaderboard->igraci[$i]->getTeamInfo()->ime; ?></a>
                            </div>
                            
                            <div class="leagueLeaderScore">
                            	<span class="leagueLeaderScoreNumber"><?php echo $leaderboard->igraci[$i]->totalStats->stl; ?></span>
                            </div>
                        </div>
                        
                    <?php
						}
					?>
                    </div><!-- end of .leagueLeaders -->
                    <h3 class="smallBoxTitle"><a href="#">Steals</a></h3>
                                        
                </div>
            </div><!-- end of middle_content -->

